package com.woniu.hystrix;

import com.woniu.api.RemoteProductServer;
import com.woniu.entity.Product;
import com.woniu.entity.ProductDTO;
import com.woniu.entity.utils.ResponseEntity;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class FallbackFactoryCommand implements FallbackFactory<RemoteProductServer> {
    @Override
    public RemoteProductServer create(Throwable cause) {
        return new RemoteProductServer() {

            @Override
            public ResponseEntity findOneById(Integer pid) {
                return ResponseEntity.TIMEOUT;
            }

            @Override
            public ResponseEntity updateProduct(Product product) {
                return ResponseEntity.TIMEOUT;
            }

            @Override
            public ResponseEntity findAllByNameOrPrice1(ProductDTO productDTO) {
                return ResponseEntity.TIMEOUT;
            }
        };
    }
}
